import java.util.HashMap;

class Product {
    public Product(int id, String name, double price) {
        this.Id = id;
        this.Name = name;
        this.Price = price;
    }

    public int Id;
    public String Name;
    public double Price;

    public Memento save() {
        return new Memento(this.Name, this.Price);
    }

    public void load(Memento memento) {
        this.Name = memento.Name;
        this.Price = memento.Price;
    }
}

public class Memento {
    public static void main(String[] args) {
        Director d = new Director();
        Product p1 = new Product(1, "Product1", 10);

        d.kvs.put("p1", p1.save());
        p1.Name = "Product1-1";
        p1.Price = 20;

        d.kvs.put("p2", p1.save());
        p1.load(d.kvs.get("p1"));
        System.out.println(String.format("%d,%s,%.2f", p1.Id, p1.Name, p1.Price));

        p1.load(d.kvs.get("p2"));
        System.out.println(String.format("%d,%s,%.2f", p1.Id, p1.Name, p1.Price));
    }

    public Memento(String name, double price) {
        this.Name = name;
        this.Price = price;
    }

    public String Name;
    public double Price;
}

class Director {
    public HashMap<String, Memento> kvs = new HashMap<String, Memento>();
}